
 /**
  * LICENCIA LGPL:
  * 
  * Esta librería es Software Libre; Usted puede redistribuirla y/o modificarla
  * bajo los términos de la GNU Lesser General Public License (LGPL) tal y como 
  * ha sido publicada por la Free Software Foundation; o bien la versión 2.1 de 
  * la Licencia, o (a su elección) cualquier versión posterior.
  * 
  * Esta librería se distribuye con la esperanza de que sea útil, pero SIN 
  * NINGUNA GARANTÍA; tampoco las implícitas garantías de MERCANTILIDAD o 
  * ADECUACIÓN A UN PROPÓSITO PARTICULAR. Consulte la GNU Lesser General Public 
  * License (LGPL) para más detalles
  * 
  * Usted debe recibir una copia de la GNU Lesser General Public License (LGPL) 
  * junto con esta librería; si no es así, escriba a la Free Software Foundation 
  * Inc. 51 Franklin Street, 5º Piso, Boston, MA 02110-1301, USA o consulte
  * <http://www.gnu.org/licenses/>.
  *
  * Copyright 2011 Agencia de Tecnología y Certificación Electrónica
  */
 package es.accv.arangi.base.util;
 
 import java.util.Map;
 import java.util.TreeMap;
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.CDATASection;
 import org.w3c.dom.Comment;
 import org.w3c.dom.DOMConfiguration;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
 import org.w3c.dom.DocumentFragment;
 import org.w3c.dom.DocumentType;
 import org.w3c.dom.Element;
 import org.w3c.dom.EntityReference;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.ProcessingInstruction;
 import org.w3c.dom.Text;
 import org.w3c.dom.UserDataHandler;
 
 /**
  * Clase necesaria para implementar la funcionalidad de añadir un atributo ID a un
  * nodo XML en Java 1.4. En Java 1.5 ya existe un método <i>setIdAttribute</i> de la
  * clase <i>Element</i> que realiza esta acción 
  * 
  * @author <a href="mailto:jgutierrez@accv.es">José M Gutiérrez</a>
  */
 public class DOMDocument implements Document {
 	
 	private Document _doc;
 	private Map _eltsById = new TreeMap();
 	
 	public DOMDocument(Document doc){
 		_doc = doc;
 	}
 	
 	public Element getElementById(String id){
 		Element foundElt = _doc.getElementById(id);
 		if (foundElt == null)
 			foundElt = (Element)_eltsById.get(id);
 		return foundElt;
 	}
 	
 	public void setIdAttribute(String attrName, Element elt){
 		String attrValue = elt.getAttribute(attrName);
 		if (attrValue != null)
 			_eltsById.put(attrValue, elt);
 	}
 	
 	//-- Todo lo demás tal y como está en la clase Document
 	   
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createAttribute(java.lang.String)
 	 */
 	public Attr createAttribute(String name) throws DOMException {
 		return _doc.createAttribute(name);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createAttributeNS(java.lang.String, java.lang.String)
 	 */
 	public Attr createAttributeNS(String namespaceURI, String qualifiedName)
 			throws DOMException {
 		return _doc.createAttributeNS(namespaceURI, qualifiedName);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createCDATASection(java.lang.String)
 	 */
 	public CDATASection createCDATASection(String data) throws DOMException {
 		return _doc.createCDATASection(data);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createComment(java.lang.String)
 	 */
 	public Comment createComment(String data) {
 		return _doc.createComment(data);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createDocumentFragment()
 	 */
 	public DocumentFragment createDocumentFragment() {
 		return _doc.createDocumentFragment();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createElement(java.lang.String)
 	 */
 	public Element createElement(String tagName) throws DOMException {
 		return _doc.createElement(tagName);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createElementNS(java.lang.String, java.lang.String)
 	 */
 	public Element createElementNS(String namespaceURI, String qualifiedName)
 			throws DOMException {
 		return _doc.createElementNS(namespaceURI, qualifiedName);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createEntityReference(java.lang.String)
 	 */
 	public EntityReference createEntityReference(String name)
 			throws DOMException {
 		return _doc.createEntityReference(name);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createProcessingInstruction(java.lang.String, java.lang.String)
 	 */
 	public ProcessingInstruction createProcessingInstruction(String target,
 			String data) throws DOMException {
 		return _doc.createProcessingInstruction(target, data);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#createTextNode(java.lang.String)
 	 */
 	public Text createTextNode(String data) {
 		return _doc.createTextNode(data);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#getDoctype()
 	 */
 	public DocumentType getDoctype() {
 		return _doc.getDoctype();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#getDocumentElement()
 	 */
 	public Element getDocumentElement() {
 		return _doc.getDocumentElement();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#getElementsByTagName(java.lang.String)
 	 */
 	public NodeList getElementsByTagName(String tagname) {
 		return _doc.getElementsByTagName(tagname);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#getElementsByTagNameNS(java.lang.String, java.lang.String)
 	 */
 	public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
 		return _doc.getElementsByTagNameNS(namespaceURI, localName);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#getImplementation()
 	 */
 	public DOMImplementation getImplementation() {
 		return _doc.getImplementation();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Document#importNode(org.w3c.dom.Node, boolean)
 	 */
 	public Node importNode(Node importedNode, boolean deep) throws DOMException {
 		return _doc.importNode(importedNode, deep);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
 	 */
 	public Node appendChild(Node newChild) throws DOMException {
 		return _doc.appendChild(newChild);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#cloneNode(boolean)
 	 */
 	public Node cloneNode(boolean deep) {
 		return _doc.cloneNode(deep);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getAttributes()
 	 */
 	public NamedNodeMap getAttributes() {
 		return _doc.getAttributes();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getChildNodes()
 	 */
 	public NodeList getChildNodes() {
 		return _doc.getChildNodes();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getFirstChild()
 	 */
 	public Node getFirstChild() {
 		return _doc.getFirstChild();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getLastChild()
 	 */
 	public Node getLastChild() {
 		return _doc.getLastChild();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getLocalName()
 	 */
 	public String getLocalName() {
 		return _doc.getLocalName();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getNamespaceURI()
 	 */
 	public String getNamespaceURI() {
 		return _doc.getNamespaceURI();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getNextSibling()
 	 */
 	public Node getNextSibling() {
 		return _doc.getNextSibling();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getNodeName()
 	 */
 	public String getNodeName() {
 		return _doc.getNodeName();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getNodeType()
 	 */
 	public short getNodeType() {
 		return _doc.getNodeType();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getNodeValue()
 	 */
 	public String getNodeValue() throws DOMException {
 		return _doc.getNodeValue();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getOwnerDocument()
 	 */
 	public Document getOwnerDocument() {
 		return _doc.getOwnerDocument();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getParentNode()
 	 */
 	public Node getParentNode() {
 		return _doc.getParentNode();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getPrefix()
 	 */
 	public String getPrefix() {
 		return _doc.getPrefix();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#getPreviousSibling()
 	 */
 	public Node getPreviousSibling() {
 		return _doc.getPreviousSibling();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#hasAttributes()
 	 */
 	public boolean hasAttributes() {
 		return _doc.hasAttributes();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#hasChildNodes()
 	 */
 	public boolean hasChildNodes() {
 		return _doc.hasChildNodes();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
 	 */
 	public Node insertBefore(Node newChild, Node refChild) throws DOMException {
 		return _doc.insertBefore(newChild, refChild);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#isSupported(java.lang.String, java.lang.String)
 	 */
 	public boolean isSupported(String feature, String version) {
 		return _doc.isSupported(feature, version);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#normalize()
 	 */
 	public void normalize() {
 		_doc.normalize();
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
 	 */
 	public Node removeChild(Node oldChild) throws DOMException {
 		return _doc.removeChild(oldChild);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
 	 */
 	public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
 		return _doc.replaceChild(newChild, oldChild);
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
 	 */
 	public void setNodeValue(String nodeValue) throws DOMException {
 		_doc.setNodeValue(nodeValue);
 
 	}
 
 	/* (non-Javadoc)
 	 * @see org.w3c.dom.Node#setPrefix(java.lang.String)
 	 */
 	public void setPrefix(String prefix) throws DOMException {
 		_doc.setPrefix(prefix);
 
 	}
 
 	public Node adoptNode(Node source) throws DOMException {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public String getDocumentURI() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public DOMConfiguration getDomConfig() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public String getInputEncoding() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public boolean getStrictErrorChecking() {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
 	public String getXmlEncoding() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public boolean getXmlStandalone() {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
 	public String getXmlVersion() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public void normalizeDocument() {
 		// TODO Auto-generated method stub
 		
 	}
 
 	public Node renameNode(Node n, String namespaceURI, String qualifiedName)
 			throws DOMException {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public void setDocumentURI(String documentURI) {
 		// TODO Auto-generated method stub
 		
 	}
 
 	public void setStrictErrorChecking(boolean strictErrorChecking) {
 		// TODO Auto-generated method stub
 		
 	}
 
 	public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
 		// TODO Auto-generated method stub
 		
 	}
 
 	public void setXmlVersion(String xmlVersion) throws DOMException {
 		// TODO Auto-generated method stub
 		
 	}
 
 	public short compareDocumentPosition(Node other) throws DOMException {
 		// TODO Auto-generated method stub
 		return 0;
 	}
 
 	public String getBaseURI() {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public Object getFeature(String feature, String version) {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public String getTextContent() throws DOMException {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public Object getUserData(String key) {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public boolean isDefaultNamespace(String namespaceURI) {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
 	public boolean isEqualNode(Node arg) {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
 	public boolean isSameNode(Node other) {
 		// TODO Auto-generated method stub
 		return false;
 	}
 
 	public String lookupNamespaceURI(String prefix) {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public String lookupPrefix(String namespaceURI) {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 	public void setTextContent(String textContent) throws DOMException {
 		// TODO Auto-generated method stub
 		
 	}
 
 	public Object setUserData(String key, Object data, UserDataHandler handler) {
 		// TODO Auto-generated method stub
 		return null;
 	}
 
 }